package pkg

import (
	"fmt"

	"github.com/nsf/termbox-go"
)

type Container struct {
	Basic
	Header *Basic // 标题
	Aside  *Basic // 侧边框
	Ｍain   *Basic // Main
	Footer *Basic // 底部
}

func (this *Container) Init() *Container {
	x, y := termbox.Size()
	this.StartX = 0
	this.StartY = 0
	this.LengthX = x - 2
	this.LengthY = y - 2
	this.Fg = termbox.ColorBlue
	this.Bg = termbox.ColorDefault
	this.SetAside().Border()
	this.SetHeader().Border()
	this.SetMain().Border()
	return this
}

// 1/5的总高度　　1/1 总宽度
func (this *Container) SetHeader() *Basic {
	tmp := &Basic{}
	tmp.StartX = this.Aside.LengthX + 1
	tmp.StartY = this.StartY
	tmp.LengthX = int(this.LengthX * 4 / 5)
	tmp.LengthY = int(this.LengthY / 5)
	tmp.Fg = termbox.ColorYellow
	this.Header = tmp
	fmt.Println(tmp)
	return tmp
}

func (this *Container) SetAside() *Basic {
	tmp := &Basic{}
	tmp.StartX = this.StartX + 1
	tmp.StartY = this.StartY + 1
	tmp.LengthX = int(this.LengthX / 5)
	tmp.LengthY = this.LengthY - 2
	tmp.Fg = termbox.ColorGreen
	this.Aside = tmp
	return tmp
}

func (this *Container) SetMain() *Basic {
	tmp := &Basic{}
	tmp.StartX = this.Header.StartX
	tmp.StartY = this.Header.StartY + this.Header.LengthY + 1
	tmp.LengthX = this.Header.LengthX
	tmp.LengthY = this.LengthY - this.Header.LengthY - 2
	tmp.Fg = termbox.ColorRed
	this.Aside = tmp
	return tmp
}
